package cn.edu.gxu.xingjian.teacherassistant.web;

import cn.edu.gxu.xingjian.teacherassistant.domain.AccountPassword;
import cn.edu.gxu.xingjian.teacherassistant.domain.Classroom;
import cn.edu.gxu.xingjian.teacherassistant.domain.College;
import cn.edu.gxu.xingjian.teacherassistant.domain.Curriculum;
import cn.edu.gxu.xingjian.teacherassistant.domain.EducationTask;
import cn.edu.gxu.xingjian.teacherassistant.domain.MajorGrade;
import cn.edu.gxu.xingjian.teacherassistant.domain.PatternRole;
import cn.edu.gxu.xingjian.teacherassistant.domain.Teacher;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.format.support.FormattingConversionServiceFactoryBean;
import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService;

@Configurable
/**
 * A central place to register application converters and formatters. 
 */
@RooConversionService
public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean {

	@Override
	protected void installFormatters(FormatterRegistry registry) {
		super.installFormatters(registry);
		// Register application converters and formatters
	}

	public Converter<AccountPassword, String> getAccountPasswordToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.AccountPassword, java.lang.String>() {
            public String convert(AccountPassword accountPassword) {
                return new StringBuilder().append(accountPassword.getAccount()).append(' ').append(accountPassword.getPassword()).toString();
            }
        };
    }

	public Converter<Long, AccountPassword> getIdToAccountPasswordConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.AccountPassword>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.AccountPassword convert(java.lang.Long id) {
                return AccountPassword.findAccountPassword(id);
            }
        };
    }

	public Converter<String, AccountPassword> getStringToAccountPasswordConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.AccountPassword>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.AccountPassword convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), AccountPassword.class);
            }
        };
    }

	public Converter<Classroom, String> getClassroomToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.Classroom, java.lang.String>() {
            public String convert(Classroom classroom) {
                return new StringBuilder().append(classroom.getPlace()).append(' ').append(classroom.getRoomNumber()).toString();
            }
        };
    }

	public Converter<Long, Classroom> getIdToClassroomConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.Classroom>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Classroom convert(java.lang.Long id) {
                return Classroom.findClassroom(id);
            }
        };
    }

	public Converter<String, Classroom> getStringToClassroomConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.Classroom>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Classroom convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Classroom.class);
            }
        };
    }

	public Converter<College, String> getCollegeToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.College, java.lang.String>() {
            public String convert(College college) {
                return new StringBuilder().append(college.getName()).toString();
            }
        };
    }

	public Converter<Long, College> getIdToCollegeConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.College>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.College convert(java.lang.Long id) {
                return College.findCollege(id);
            }
        };
    }

	public Converter<String, College> getStringToCollegeConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.College>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.College convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), College.class);
            }
        };
    }

	public Converter<Curriculum, String> getCurriculumToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.Curriculum, java.lang.String>() {
            public String convert(Curriculum curriculum) {
                return new StringBuilder().append(curriculum.getName()).append(' ').append(curriculum.getCredit()).append(' ').append(curriculum.getCurriculumNumber()).append(' ').append(curriculum.getTeachingHours()).toString();
            }
        };
    }

	public Converter<Long, Curriculum> getIdToCurriculumConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.Curriculum>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Curriculum convert(java.lang.Long id) {
                return Curriculum.findCurriculum(id);
            }
        };
    }

	public Converter<String, Curriculum> getStringToCurriculumConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.Curriculum>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Curriculum convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Curriculum.class);
            }
        };
    }

	public Converter<EducationTask, String> getEducationTaskToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.EducationTask, java.lang.String>() {
            public String convert(EducationTask educationTask) {
                return new StringBuilder().append(educationTask.getClassSize()).toString();
            }
        };
    }

	public Converter<Long, EducationTask> getIdToEducationTaskConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.EducationTask>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.EducationTask convert(java.lang.Long id) {
                return EducationTask.findEducationTask(id);
            }
        };
    }

	public Converter<String, EducationTask> getStringToEducationTaskConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.EducationTask>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.EducationTask convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), EducationTask.class);
            }
        };
    }

	public Converter<MajorGrade, String> getMajorGradeToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.MajorGrade, java.lang.String>() {
            public String convert(MajorGrade majorGrade) {
                return new StringBuilder().append(majorGrade.getName()).append(' ').append(majorGrade.getGrade()).append(' ').append(majorGrade.getClasses()).toString();
            }
        };
    }

	public Converter<Long, MajorGrade> getIdToMajorGradeConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.MajorGrade>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.MajorGrade convert(java.lang.Long id) {
                return MajorGrade.findMajorGrade(id);
            }
        };
    }

	public Converter<String, MajorGrade> getStringToMajorGradeConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.MajorGrade>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.MajorGrade convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), MajorGrade.class);
            }
        };
    }

	public Converter<PatternRole, String> getPatternRoleToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.PatternRole, java.lang.String>() {
            public String convert(PatternRole patternRole) {
                return new StringBuilder().append(patternRole.getPatternRoles()).toString();
            }
        };
    }

	public Converter<Long, PatternRole> getIdToPatternRoleConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.PatternRole>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.PatternRole convert(java.lang.Long id) {
                return PatternRole.findPatternRole(id);
            }
        };
    }

	public Converter<String, PatternRole> getStringToPatternRoleConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.PatternRole>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.PatternRole convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), PatternRole.class);
            }
        };
    }

	public Converter<Teacher, String> getTeacherToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.Teacher, java.lang.String>() {
            public String convert(Teacher teacher) {
                return new StringBuilder().append(teacher.getName()).append(' ').append(teacher.getAge()).append(' ').append(teacher.getWorkingNumber()).append(' ').append(teacher.getSex()).toString();
            }
        };
    }

	public Converter<Long, Teacher> getIdToTeacherConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.Teacher>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Teacher convert(java.lang.Long id) {
                return Teacher.findTeacher(id);
            }
        };
    }

	public Converter<String, Teacher> getStringToTeacherConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.Teacher>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Teacher convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Teacher.class);
            }
        };
    }

	public void installLabelConverters(FormatterRegistry registry) {
        registry.addConverter(getAccountPasswordToStringConverter());
        registry.addConverter(getIdToAccountPasswordConverter());
        registry.addConverter(getStringToAccountPasswordConverter());
        registry.addConverter(getClassroomToStringConverter());
        registry.addConverter(getIdToClassroomConverter());
        registry.addConverter(getStringToClassroomConverter());
        registry.addConverter(getCollegeToStringConverter());
        registry.addConverter(getIdToCollegeConverter());
        registry.addConverter(getStringToCollegeConverter());
        registry.addConverter(getCurriculumToStringConverter());
        registry.addConverter(getIdToCurriculumConverter());
        registry.addConverter(getStringToCurriculumConverter());
        registry.addConverter(getEducationTaskToStringConverter());
        registry.addConverter(getIdToEducationTaskConverter());
        registry.addConverter(getStringToEducationTaskConverter());
        registry.addConverter(getMajorGradeToStringConverter());
        registry.addConverter(getIdToMajorGradeConverter());
        registry.addConverter(getStringToMajorGradeConverter());
        registry.addConverter(getPatternRoleToStringConverter());
        registry.addConverter(getIdToPatternRoleConverter());
        registry.addConverter(getStringToPatternRoleConverter());
        registry.addConverter(getTeacherToStringConverter());
        registry.addConverter(getIdToTeacherConverter());
        registry.addConverter(getStringToTeacherConverter());
    }

	public void afterPropertiesSet() {
        super.afterPropertiesSet();
        installLabelConverters(getObject());
    }
}
